﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using am.Charts;

namespace amCharts
{
    public partial class Line : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //自己添加一个数据
            DataSet ds = new DataSet("Line");
            DataTable dt = new DataTable("LineTable");
            DataColumn dc_y = new DataColumn("year");
            DataColumn dc_v = new DataColumn("val");

            DataColumn dc_v1 = new DataColumn("val1");

            dt.Columns.Add(dc_y);
            dt.Columns.Add(dc_v);
            dt.Columns.Add(dc_v1);
            Random rd = new Random();
            for (int i = 1987; i < 2010; i++)
            {
                DataRow dr = dt.NewRow();
                dr[dc_y] = i.ToString();
                dr[dc_v] = (rd.NextDouble() * i).ToString();
                dr[dc_v1] = (rd.NextDouble() * (i + i / 3)).ToString();
                dt.Rows.Add(dr);
            }
            ds.Tables.Add(dt);

            //设置图形的长高
            LineChart1.Width = new Unit(600);
            LineChart1.Height = new Unit(400);

            //添加一个线条
            LineChartGraph lcg = new LineChartGraph();
            //这里是线条峰点的形状(正方形):实心圆,空心圆....
            lcg.Bullet = LineChartBulletTypes.RoundOutline;
            //这里是线条的颜色
            //lcg.BulletColor = Color.Yellow;
            //向下面积的颜色
            //lcg.FillColor = Color.Yellow;
            ////向下面积的透明度
            //lcg.FillAlpha = Convert.ToByte(40);
            ////Y轴值在右边(默认在左边)
            //lcg.Axis = LineChartAxes.Right;

            lcg.DataSource = ds;
            lcg.DataSeriesItemIDField = "year";
            lcg.DataValueField = "val";
            lcg.Title = "测试1";
            LineChart1.Graphs.Add(lcg);

            //添加第二个线条
            LineChartGraph lcg1 = new LineChartGraph();
            lcg1.Bullet = LineChartBulletTypes.RoundOutline;

            lcg1.DataSource = ds;
            lcg1.DataSeriesItemIDField = "year";
            lcg1.DataValueField = "val1";
            lcg1.Title = "测试2";
            LineChart1.Graphs.Add(lcg1);

            LineChart1.DataSource = ds;
            LineChart1.DataSeriesIDField = "year";
            LineChart1.DataBind();

        }
    }
}
